﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


using DBBase;
using System.Threading;
using System.Xml;


using System.IO;

using System.Web;
using System.Runtime.InteropServices;
using System.IO.Ports;
using System.Security;
using System.Security.Cryptography;

namespace Business
{
    public partial class Interface : Form
    {
        public static string szzjg;
        public Interface()
        {
            InitializeComponent();
            getjilury();
            getjilu();
            szzjg = "";
        }
        public void getjilury()
        {
            Query objquery = new Query();
            string ssqlex = "";
            ssqlex = string.Format(@"select distinct ZZJG from USERE order by ZZJG ");
            DataTable dt = objquery.GetTable(ssqlex);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                com_jsmc.Items.Add(dt.Rows[i]["ZZJG"].ToString().Trim());
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
           
        }
        public void getjilu()
        {
            lv.Items.Clear();
            Query mquery = new Query();
            string sql;
            sql = string.Format(@"Select * from ShouQuan ");

            //try
            {
                DataTable dt = mquery.GetTable(sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ListViewItem lt = new ListViewItem(dt.Rows[i]["SQ_ZJJG"].ToString().Trim());
                       
                        lt.SubItems.Add(dt.Rows[i]["SQ_JKMS"].ToString().Trim());
                        lt.SubItems.Add((dt.Rows[i]["SQ_JKSQM"].ToString().Trim()));
                        lt.SubItems.Add(dt.Rows[i]["SQ_FWDZ"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["SQ_SQRQ"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["SQ_SQR"].ToString().Trim());
                        this.lv.Items.Add(lt);



                    }
                }


            }



        }

      

        private void lv_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lv.SelectedItems)
            {
                szzjg = item.SubItems[0].Text.ToString().Trim();
            }
        }

        private void but_add_Click(object sender, EventArgs e)
        {
            if (com_jsmc.Text == "")
            {
                MessageBox.Show("组织机构不能为空");
            }
            else
            {
                jiekoushezhi m_wjxm = new jiekoushezhi(com_jsmc.Text);
                m_wjxm.ShowDialog();
            }
        }

        private void but_delete_Click(object sender, EventArgs e)
        {
            if (szzjg == "")
            {
                MessageBox.Show("请先选择组织机构");
            }
            else
            {
                Query objquery = new Query();
                string ssqlex = "";
                ssqlex = string.Format(@"delete ShouQuan where SQ_ZJJG='{0}' ", szzjg);
                if (!objquery.UpdateTable(ssqlex))
                {
                    MessageBox.Show("删除失败");
                }
            }
        }
    }
}
